//
//  ObjKeyUserInfo.m
//  SX_DataModel
//
//  Created by Ganide on 2018/7/9.
//  Copyright © 2018年 Ganide. All rights reserved.
//

#import "ObjKeyUserInfo.h"
#import <UIKit/UIKit.h>
@implementation ObjKeyUserInfo
+(ObjKeyUserInfo *)setKeyInfo:(const char *)charactor nameKey:(NSString *)nameKey{
    ObjKeyUserInfo *userInfo = [[ObjKeyUserInfo alloc] init];
    char *struc = "{?=";
    char *uni = "(?=";
    userInfo.name = nameKey;
    NSString *objStrct = [NSString stringWithUTF8String:struc];
    NSString *objUni = [NSString stringWithUTF8String:uni];
    if (strcmp(charactor, "i")==0) {
        userInfo.keyType = keyTypeChar;
        userInfo.dataClass = [@('a') class];
    }else if (strcmp(charactor, "C")==0){
        userInfo.keyType = keyTypeUnchar;
        userInfo.dataClass = [@('a') class];
    }else if (strcmp(charactor, "v")==0){
        userInfo.keyType = keyTypeVoid;
    }else if (strcmp(charactor, "@\"NSString\"")==0||strcmp(charactor, "@\"NSMutableString\"")==0){
        userInfo.keyType = keyTypeString;
        userInfo.dataClass = [NSString class];
    }else if (strcmp(charactor, "@\"NSURL\"")==0){
        userInfo.keyType = keyTypeURL;
        userInfo.dataClass = [NSURL class];
    }else if (strcmp(charactor, "@\"NSArray\"")==0 || strcmp(charactor, "@\"NSMutableArray\"")==0){
        userInfo.keyType = keyTypeArray;
        userInfo.dataClass = [NSArray class];
    }else if (strcmp(charactor, "@\"NSDictionary\"")==0 || strcmp(charactor, "@\"NSMutableDictionary\"")==0){
        userInfo.keyType = keyTypeDictionry;
        userInfo.dataClass = [NSDictionary class];
    }else if (strcmp(charactor, "@\"NSSet\"")==0 || strcmp(charactor, "@\"NSMutableSet\"")==0){
        userInfo.keyType = keyTypeSet;
        userInfo.dataClass = [NSSet class];
    }else if (strcmp(charactor, "@\"NSValue\"")==0){
        userInfo.keyType = keyTypeValue;
        userInfo.dataClass = [NSValue class];
    }else if (strcmp(charactor, "@\"NSNumber\"")==0){
        userInfo.keyType = keyTypeNumber;
        userInfo.dataClass = [NSNumber class];
    }else if (strcmp(charactor, "@\"NSMutableData\"")==0||strcmp(charactor, "@\"NSData\"")==0){
        userInfo.keyType = keyTypeData;
        userInfo.dataClass = [NSData class];
    }else if (strcmp(charactor, "@\"NSDate\"")==0){
        userInfo.keyType = keyTypeDate;
    } else if (strcmp(charactor, "i")==0){
        userInfo.keyType = keyTypeInt;
        userInfo.dataClass = [@(1) class];
    }else if (strcmp(charactor, "s")==0){
        short i = 1;
        userInfo.keyType = keyTypeShort;
        userInfo.dataClass = [@(i) class];
    }else if (strcmp(charactor, "I")==0){
        u_int i = 1;
        userInfo.keyType = keyTypeUnint;
        userInfo.dataClass = [@(i) class];
    }else if (strcmp(charactor, "q")==0){
        long long i = 1;
        userInfo.keyType = keyTypeLongLong;
        userInfo.dataClass = [@(i) class];
    }else if (strcmp(charactor, "l")==0){
        userInfo.keyType = keyTypeLong;
        long i = 1;
        userInfo.dataClass = [@(i) class];
    }else if (strcmp(charactor, "S")==0){
        userInfo.keyType = keyTypeUnShort;
        u_short i = 1;
        userInfo.dataClass = [@(i) class];
    }else if (strcmp(charactor, "L")==0){
        userInfo.keyType = keyTypeUnLong;
        u_long i = 1;
        userInfo.dataClass = [@(i) class];
    }else if (strcmp(charactor, "Q")==0){
        userInfo.keyType = keyTypeUnLongLong;
      u_long  i = 1;
        userInfo.dataClass = [@(i) class];
    }else if (strcmp(charactor, "f")==0){
        userInfo.keyType = keyTypeFloat;
        float i = 1.0;
        userInfo.dataClass = [@(i) class];
    }else if (strcmp(charactor, "d")==0){
        userInfo.keyType = keyTypeDouble;
        double i = 1.0;
        userInfo.dataClass = [@(i) class];
    }else if (strcmp(charactor, "B")==0){
        userInfo.keyType = keyTypeBool;
        BOOL i = 1;
        userInfo.dataClass = [@(i) class];
    }else if (strcmp(charactor, "D")==0){
        userInfo.keyType = keyTypeLongDouble;
        double i = 1.0;
        userInfo.dataClass = [@(i) class];
    }else if (strcmp(charactor, "{CGRect={CGPoint=dd}{CGSize=dd}}")==0){
        userInfo.keyType = keyTypeRect;
        userInfo.dataClass = [@(CGRectMake(0, 0, 0, 0)) class];
    }else if (strcmp(charactor, "{CGPoint=dd}")==0){
        userInfo.keyType = keyTypePoint;
        userInfo.dataClass = [@(CGPointMake(0.0, 0.0)) class];
    }else if (strcmp(charactor, "{CGSize=dd}")==0){
        userInfo.keyType = keyTypeSize;
        userInfo.dataClass = [@(CGSizeMake(0.0, 0.0)) class];
    }else if (strcmp(charactor, "{_NSRange=QQ}")==0){
        userInfo.keyType = keyTypeRange;
        userInfo.dataClass = [[NSValue valueWithRange:NSMakeRange(0, 0)] class];
    }else if ([[NSString stringWithUTF8String:charactor] containsString:objStrct]){
        userInfo.keyType = keyTypeStruct;
    }else if ([[NSString stringWithUTF8String:charactor] containsString:objUni]){
        userInfo.keyType = keyTypeUnion;
    }else if (strcmp(charactor, "?")==0){
        userInfo.keyType = keyTypeUnknown;
    }else if (strcmp(charactor, "bnum")==0){
        userInfo.keyType = keyTypebit;
//        Byte bit;
//        userInfo.dataClass = [[NSValue ] class];
    }else if (strcmp(charactor, "^type")==0){
        userInfo.keyType = keyTypePointer;
    }else if(strcmp(charactor, "*")==0){
        userInfo.keyType = keyTypeClass;
    }else if (strcmp(charactor, ":")==0){
        userInfo.keyType = keyTypeSelector;
    }else if (strcmp(charactor, "@")==0){
        userInfo.keyType = keyTypeObj;
    }else{
        userInfo.keyType = keyTypeOtherObj;
    }
    return userInfo;
}

@end


